package main;

import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;

import ord_list.*;
public class Test {
	public static void main(String[] args) {
		OrderedLinkedList<Integer> il = new OrderedLinkedList<Integer>();
		for (int i = 4; i < 7; i += 2)
			il.add(i);
		for (int i = 5; i < 8; i += 2)
			assert il.add(i);
		for (int i = 0; i < 4; i++)
			assert il.add(i);
		for (int i = 8; i < 10; i++)
			assert il.add(i);
		for (int i = 0; i < 10; i++)
			assert !(il.add(i));
		
		assert il.toString().equals("[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
		assert il.contains(0) && il.contains(5) && il.contains(9);
		assert !(il.contains(-1) || il.contains(10));
		for (int i = 0; i < 10; i++)
			assert il.contains(i);
		
		OrderedLinkedList<Integer> il2 = new OrderedLinkedList<>(il.iterator());
		
		assert il.equals(il);
		assert il.equals(il2);
		assert il2.equals(il);
		
		assert il.compareTo(il) == 0;
		assert il.compareTo(il2) == 0;
		assert il2.compareTo(il) == 0;
		
		assert !il.remove(-1);
		assert !il.remove(10);
		
		assert il.toString().equals("[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
		
		assert il.remove(0);
		assert il.compareTo(il2) > 0;
		assert il2.compareTo(il) < 0;
		
		assert il2.remove(0);
		assert il.remove(9);
		assert il.compareTo(il2) < 0;
		assert il2.compareTo(il) > 0;
		
		assert il2.remove(9);
		assert il.remove(5);
		assert il.toString().equals("[1, 2, 3, 4, 6, 7, 8]");
		assert il.size() == 7;
		assert il.compareTo(il2) > 0;
		assert il2.compareTo(il) < 0;
		
		OrderedList<Calendar> cl1 = new OrderedLinkedList<Calendar>(Arrays.<Calendar>
										asList(new GregorianCalendar(2007, 1, 27), 
										new GregorianCalendar(2004, 7, 20)).iterator());
		
		
		/* Bound mismatch: The type GregorianCalendar is not a valid substitute 
		 * for the bounded parameter <E extends Comparable<E>> of the type 
		 * OrderedList<E> */
//		OrderedList<GregorianCalendar> cl2 = null;
//		assert !cl1.equals(cl2);
//		cl2 = new OrderedLinkedList<GregorianCalendar>(
//				Arrays.<GregorianCalendar> asList(new GregorianCalendar(2001,
//						8, 21), new GregorianCalendar(1972, 10, 17)));
		
//		assert cl2.compareTo(cl2) == 0;
//		assert cl1.compareTo(cl2) > 0;
		
		
		assert cl1.compareTo(cl1) == 0;
		System.out.println("TESTS PASSED");
	}
}
